package com.teacher.hong.dao;

import com.teacher.hong.entity.BorrowRecord;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
import javax.annotation.Resource;
import java.sql.SQLException;

/**
 * 借钱记录DAO
 */
@Repository
public class BorrowRecordDao {

    @Resource
    JdbcTemplate jdbcTemplate;


    /**
     * 新增借钱记录
     * @param borrowRecord
     * @return
     */
    public int insert(BorrowRecord borrowRecord) throws SQLException {
        return jdbcTemplate.update("insert into borrow_record values(default, ?, ?, ?, now())",
                borrowRecord.getStudent1Id(), borrowRecord.getStudent2Id(), borrowRecord.getMoney());
    }

}
